package com.toocms.jinjuhang.ui.mine.contact_us

import android.content.Intent
import android.net.Uri
import androidx.databinding.ObservableField
import com.blankj.utilcode.util.ActivityUtils
import com.toocms.tab.base.ItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class ContactUsTelItemModel(
    viewModel: ContactUsModel,
    val title: ObservableField<String>,
    val phoneCode: ObservableField<String>,
    val extend: ObservableField<String>
) : ItemViewModel<ContactUsModel>(viewModel) {
    val itemClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        if (phoneCode.get().isNullOrEmpty()) return@BindingAction
        val intent = Intent(Intent.ACTION_DIAL)
        intent.data = Uri.parse("tel:${phoneCode.get()}")
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        ActivityUtils.getTopActivity().startActivity(intent)
    })
}